﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using QLNSWPF2.ToolSupport;
using System.Data;

namespace QLNSWPF2
{
    /// <summary>
    /// Interaction logic for Login.xaml
    /// </summary>
    public partial class Login : Window
    {
        DataConnection dataConnection;
        public Login()
        {
            InitializeComponent();
            dataConnection = new DataConnection();
        }

        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            string username = txtUsername.Text;
            string password = txtPassword.Text;
            DataTable table = dataConnection.ExecuteDataTableAll("select * from Users where Username='" + username + "' and Password='" + password + "'", CommandType.Text);
            if (table.Rows.Count > 0)
            {
                //MainWindow main = new MainWindow();
                //main.Show();
                this.Hide();
            }
            else
                MessageBox.Show("Đăng nhập thất bại!");                
        }

        private void Window_Closed(object sender, EventArgs e)
        {
                   
        }
    }
}
